<div>
  <mat-form-field class="textInput">
    <mat-select
             placeholder="Policy"
             [(ngModel)]="type"
             (change)="changeType()">
      <mat-option *ngFor="let opt of types; let i = index" [value]="opt">
        {{ display[i] }}
      </mat-option>
    </mat-select>
  </mat-form-field>
</div>

<div *ngIf="type == TYPE.SCRIPT">
  <mat-form-field class="textInput">
    <input matInput
           i18n-placeholder="services.form.label.attrRelease.policies.scriptFile"
           [placeholder]="messages.services_form_label_attrRelease_policies_scriptFile"
           [(ngModel)]="data.service.attributeReleasePolicy.scriptFile">
  </mat-form-field>
  <mat-icon style="font-size: medium"
           i18n-matTooltip="services.form.tooltip.attrRelease.policies.scriptFile"
           [matTooltip]="messages.services_form_tooltip_attrRelease_policies_scriptFile">help
  </mat-icon>
</div>

<div *ngIf="type == TYPE.GROOVY">
  <mat-form-field class="textInput">
    <input matInput
           i18n-placeholder="services.form.label.attrRelease.policies.scriptFile"
           [placeholder]="messages.services_form_label_attrRelease_policies_scriptFile"
           [(ngModel)]="data.service.attributeReleasePolicy.groovyScript">
  </mat-form-field>
  <mat-icon style="font-size: medium"
           i18n-matTooltip="services.form.tooltip.attrRelease.policies.scriptFile"
           [matTooltip]="messages.services_form_tooltip_attrRelease_policies_scriptFile">help
  </mat-icon>
</div>

<div *ngIf="(type == TYPE.RETURN_ALLOWED || type == TYPE.METADATA) && !isEmpty( formData.availableAttributes )">
  <mat-form-field class="textInput">
    <mat-select multiple
                i18n-placeholder="services.form.label.attrRelease.policies.returnAllowed"
                [placeholder]="messages.services_form_label_attrRelease_policies_returnAllowed"
                [(ngModel)]="data.service.attributeReleasePolicy.allowedAttributes">
      <mat-option *ngFor="let opt of formData.availableAttributes" [value]="opt">
        {{ opt }}
      </mat-option>
    </mat-select>
  </mat-form-field>
  <mat-icon style="font-size: medium"
           i18n-matTooltip="services.form.tooltip.attrRelease.policies.returnAllowed"
           [matTooltip]="messages.services_form_tooltip_attrRelease_policies_returnAllowed">help
  </mat-icon>
</div>

<div *ngIf="type == TYPE.RETURN_MAPPED && !isEmpty( formData.availableAttributes )">
  <app-mappedattributes [attributes]="data.service.attributeReleasePolicy.allowedAttributes"></app-mappedattributes>
</div>

<div *ngIf="type == TYPE.METADATA" style="padding-top:25px;">
  <div>
    <mat-form-field class="textInput">
      <input matInput
             i18n-placeholder="services.form.label.attrRelease.entityAttribute"
             [placeholder]="messages.services_form_label_attrRelease_entityAttribute"
             [(ngModel)]="data.service.attributeReleasePolicy.entityAttribute">
    </mat-form-field>
    <mat-icon style="font-size: medium"
             i18n-matTooltip="services.form.tooltip.attrRelease.entityAttribute"
             [matTooltip]="messages.services_form_tooltip_attrRelease_policies_entityAttribute">help
    </mat-icon>
  </div>

  <div>
    <mat-form-field class="textInput">
      <input matInput
             i18n-placeholder="services.form.label.attrRelease.entityAttributeFormat"
             [placeholder]="messages.services_form_label_attrRelease_entityAttributeFormat"
             [(ngModel)]="data.service.attributeReleasePolicy.entityAttributeFormat">
    </mat-form-field>
    <mat-icon style="font-size: medium"
             i18n-matTooltip="services.form.tooltip.attrRelease.entityAttributeFormat"
             [matTooltip]="messages.services_form_tooltip_attrRelease_entityAttributeFormat">help
    </mat-icon>
  </div>

  <div>
    <mat-form-field class="textInput">
      <input matInput
             i18n-placeholder="services.form.label.attrRelease.entityAttributeValues"
             [placeholder]="messages.services_form_label_attrRelease_entityAttributeValues"
             [ngModel]="data.service.attributeReleasePolicy.entityAttributeValues"
             (ngModelChange)="data.service.attributeReleasePolicy.entityAttributeValues = $event.split(',')">
    </mat-form-field>
    <mat-icon style="font-size: medium"
             i18n-matTooltip="services.form.tooltip.attrRelease.entityAttribute"
             [matTooltip]="messages.services_form_tooltip_attrRelease_entityAttributeValues">help
    </mat-icon>
  </div>

</div>
